package ua.kpi.transport.servlet.actions.deleting;

import ua.kpi.transport.servlet.actions.lists.TypesListAction;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ua.kpi.transport.db.dao.factory.DAOFactory;
import ua.kpi.transport.db.dao.factory.DBEnum;
import ua.kpi.transport.db.dao.interfaces.ITransportTypeDAO;
import ua.kpi.transport.servlet.actions.IAction;

/**
 *
 * @author harker777
 */
public class DeleteTypeAction implements IAction {

    @Override
    public String execute(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        ITransportTypeDAO ttd = DAOFactory.getDAOFactory(DBEnum.MYSQL).getTransportTypeDAO();
        Integer id = Integer.valueOf(request.getParameter("id"));
        ttd.delete(ttd.find(id));

        return new TypesListAction().execute(request, response);
    }
}
